<?php
/*
 * SAE Memcache 封装类
 */
class Mem
{
	public static $mc;
	
	private function __construct(){}
	
	private static function _init()
	{
		if (empty(self::$mc)){
			self::$mc = memcache_init();
			if (self::$mc == false){
				Util::log('Memcache init failed');
			}
		}
	}
	
	public static function set($key, $value, $time = 6000)
	{
		self::_init();
		return memcache_set (self::$mc, $key, $value, 0, $time);
	}
	
	public static function get($key)
	{
		self::_init();
		return memcache_get (self::$mc, $key);
	}
	
	public static function delete()
	{
		self::_init();
		return memcache_delete (self::$mc, $key);
	}
}